
import React, { Component } from 'react';
import {
  Platform,
  StyleSheet,
  Text,
  View,
  Image,
  TouchableOpacity,
  Switch,
} from 'react-native';
export default class CommonCell extends Component {
  constructor(props){
    super(props);
    this.state={
      isOn:false,
    };
  }
  /*
  getDefaultProps(){
    return{
      title:'',
    }
  }
  */
  renderRightView(){
    // return (
    //   <View style={{flexDirection:'row',alignItems:'center'}}>
    //     {this.rightTitle()}
    //     <Image source={{uri:'../../images/mine/arrow_right.png'}} style={{width:8,height:13,marginRight:10}}/>
    //   </View>
    // );
    if(this.props.rightImg){
      return (
        <View style={{flexDirection:'row',alignItems:'center'}}>
          <Image source={require('../../images/mine/icon_head2.png')} style={{width:60,height:60,}}/>
          <Image source={require('../../images/mine/arrow_right.png')} style={styles.rightArrowImg}/>
        </View>
      );
    } else if(this.props.rightText && this.props.rightArrow){
      return(
        <View style={{flexDirection:'row',alignItems:'center'}}>
          <Text style={{color:'#aaa',marginRight:3}}>{this.props.rightText}</Text>
          <Image source={require('../../images/mine/arrow_right.png')} style={styles.rightArrowImg}/>
        </View>
      )
    } else if(this.props.rightText){
      return(
        <Text style={{color:'#aaa',marginRight:3}}>{this.props.rightText}</Text>
      )
    } else if(this.props.rightArrow){
      return(
        <View style={{flexDirection:'row',alignItems:'center'}}>
          <Image source={require('../../images/mine/arrow_right.png')} style={styles.rightArrowImg}/>
        </View>
      )
    }
  }
  render() {
    return (
      <TouchableOpacity onPress={this.props.press} activeOpacity={this.props.activeOpacity?this.props.activeOpacity:0.6}>
        <View style={[styles.container,this.props.style]}>
          <Text style={styles.titleText}>{this.props.title}</Text>
          {this.renderRightView()}
        </View>
      </TouchableOpacity>
    );
  }
}

const styles = StyleSheet.create({
  rightArrowImg:{
    width:16,
    height:16,
    marginLeft:5,
    marginRight:5,
    paddingRight:2,
  },
  titleText:{
    marginLeft:0,
    fontSize:14,
    paddingTop:3,
    paddingBottom:3,
    color: '#555'
  },
  container:{
    paddingTop:10,
    paddingBottom:10,
    marginLeft:10,
    marginRight:10,
    backgroundColor:'white',
    borderBottomColor:"#ddd",
    borderBottomWidth:0.5,
    flexDirection:'row',
    justifyContent:'space-between',
    alignItems:'center',
  },
});
